package ExtraDemo.demo05.MyThreadAtom;

public class MyAtomThread implements Runnable {
    private volatile int count = 0; //送冰淇淋的数量

    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            //1.从共享数据读取数据到本线程栈中
            //2.修改本线程栈中变量副本的值
            //3.会把本线程栈中变量副本的值赋值给共享数据
            //在执行这三步中，cpu的执行权都可能会被另外的线程抢走
            count++;
            System.out.println("已经送了"+count+"个冰淇淋");
        }
    }
}
